import { getAuthorization, setAuthorization } from "@/utils/auth.js"
// 遍历
// const traversal= (data,newName,oldName) => {
//     data.forEach( o => {
//         o.text = 
//         o[newName] = o[oldName]
//     });
// }

// 获取用户id 
export const UserIdFn = () => {
    let userInfoStr = getAuthorization('userId')
    return userInfoStr
}

// 时间转换
export const timer = (num, types) => {
    let date = num
    let Year = date.getFullYear();
    let Moth = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
    let Day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
    let Hour = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
    let Minute = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
    let Sechond = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
    if (types == 'y-m-d') {
        return Year + '年' +  Moth + '月' + Day + '日'
    }

    if (types == 'm-d') {
        return Moth + '月' + Day + '日'
    }


    if (types == 'm-d h:m') {
        return Moth + '月' + Day + '日 '+ Hour + ':'+ Minute 
    }
}